package com.company;

//反转一个单链表。
public class LeetCode206 {
    public ListNode reverseList(ListNode head) {
        //设置一个前向指针一开始指向空
        ListNode prev = null;
        //设置一个当前节点一开始指向头结点
        ListNode curr = head;
        while (curr != null) {
            ListNode nextTemp = curr.next;
            curr.next = prev;
            prev = curr;
            curr = nextTemp;
        }
        return prev;
    }
}
